package com.aspose.cells;

class zta {
   private Workbook a;
   private Worksheet b;
   private zol c;
   private PageSetup d;

   zta(zol var1) {
      this.c = var1;
      this.a = var1.b;
      this.b = var1.a;
      this.d = this.b.getCharts().get(0).getPageSetup();
   }

   void a(zcfx var1) throws Exception {
      var1.b(true);
      var1.b("chartsheet");
      if (zase.a) {
         var1.a("xmlns", zase.c);
      } else {
         var1.a("xmlns", zase.d);
      }

      var1.a("xmlns", "r", (String)null, "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
      this.d(var1);
      this.c(var1);
      this.b(var1);
      this.a(var1, this.d);
      this.a(var1, this.d, this.c.s);
      this.b(var1, this.d);
      if (this.c.m.a != null) {
         var1.b("drawing");
         var1.a("r:id", (String)null, this.c.m.a);
         var1.b();
      }

      if (this.c.n.a != null) {
         var1.b("legacyDrawing");
         var1.a("r:id", (String)null, this.c.n.a);
         var1.b();
      }

      if (this.c.l.a != null) {
         var1.b("legacyDrawingHF");
         var1.a("r:id", (String)null, this.c.l.a);
         var1.b();
      }

      if (this.c.r != null) {
         var1.b("picture");
         var1.a("r:id", (String)null, this.c.r);
         var1.b();
      }

      var1.b();
      var1.d();
      var1.e();
   }

   private void b(zcfx var1) throws Exception {
      if (this.b.n != null && this.b.n.getCount() != 0) {
         var1.b("customSheetViews");

         for(int var2 = 0; var2 < this.b.n.getCount(); ++var2) {
            znb var3 = this.b.n.a(var2);
            var1.b("customSheetView");
            a(var1, var3);
            this.a(var1, var3.e());
            this.a(var1, (PageSetup)var3.e(), (String)null);
            this.b(var1, var3.e());
            var1.b();
         }

         var1.b();
      }

   }

   private static void a(zcfx var0, znb var1) throws Exception {
      int var2 = var1.I();
      if (var2 < 64) {
         var0.a("colorId", zase.y(var2));
      }

      var0.a("guid", "{" + com.aspose.cells.b.a.zr.a(var1.n) + "}");
      if (var1.p()) {
         var0.a("filter", "1");
      }

      if (var1.q()) {
         var0.a("filterUnique", "1");
      }

      if (!var1.e().isPercentScale()) {
         var0.a("fitToPage", "1");
      }

      if (var1.l()) {
         var0.a("hiddenColumns", "1");
      }

      if (var1.k()) {
         var0.a("hiddenRows", "1");
      }

      if (!var1.B()) {
         var0.a("outlineSymbols", "0");
      }

      if (var1.r()) {
         var0.a("printArea", "1");
      }

      if (var1.D() != 100) {
         var0.a("scale", zase.y(var1.D()));
      }

      if (var1.o()) {
         var0.a("showAutoFilter", "1");
      }

      if (var1.v()) {
         var0.a("showFormulas", "1");
      }

      if (!var1.w()) {
         var0.a("showGridLines", "0");
      }

      if (var1.n()) {
         var0.a("showPageBreaks", "1");
      }

      if (!var1.x()) {
         var0.a("showRowCol", "0");
      }

      if (var1.E() == 2 && !var1.G()) {
         var0.a("showRuler", "0");
      }

      String var3;
      if (var1.F() != 0) {
         var3 = "hidden";
         if (var1.F() == 2) {
            var3 = "veryHidden";
         }

         var0.a("state", var3);
      }

      var3 = CellsHelper.columnIndexToName(var1.j()) + zase.y(var1.i() + 1);
      var0.a("topLeftCell", var3);
      String var4 = zase.aq(var1.E());
      if (var4 != null) {
         var0.a("view", var4);
      }

      if (!var1.A()) {
         var0.a("showZeros", "0");
      }

   }

   private void a(zcfx var1, PageSetup var2) throws Exception {
      var1.b("pageMargins");
      var1.a("left", zase.b(var2.getLeftMarginInch()));
      var1.a("right", zase.b(var2.getRightMarginInch()));
      var1.a("top", zase.b(var2.getTopMarginInch()));
      var1.a("bottom", zase.b(var2.getBottomMarginInch()));
      var1.a("header", zase.b(var2.getHeaderMarginInch()));
      var1.a("footer", zase.b(var2.getFooterMarginInch()));
      var1.b();
   }

   private void a(zcfx var1, PageSetup var2, String var3) throws Exception {
      if (var2 != null && var2.e()) {
         var1.b("pageSetup");
         if (var2.getBlackAndWhite()) {
            var1.a("blackAndWhite", "1");
         }

         if (var2.getPrintComments() != 1) {
            var1.a("cellComments", zase.b(var2.getPrintComments()));
         }

         if (var2.getPrintDraft()) {
            var1.a("draft", "1");
         }

         if (var2.getPrintErrors() != 2) {
            var1.a("errors", zase.c(var2.getPrintErrors()));
         }

         if (!var2.isAutoFirstPageNumber()) {
            var1.a("firstPageNumber", zase.y(var2.getFirstPageNumber()));
            var1.a("useFirstPageNumber", "1");
         }

         if (var2.getFitToPagesTall() != 1) {
            var1.a("fitToHeight", zase.y(var2.getFitToPagesTall()));
         }

         if (var2.getFitToPagesWide() != 1) {
            var1.a("fitToWidth", zase.y(var2.getFitToPagesWide()));
         }

         if (var2.getPrintQuality() > 0 && var2.getPrintQuality() != 600) {
            var1.a("horizontalDpi", zase.y(var2.getPrintQuality()));
            var1.a("verticalDpi", zase.y(var2.getPrintQuality()));
         }

         var1.a("orientation", zase.a(var2.getOrientation()));
         if (var2.getOrder() != 0) {
            var1.a("pageOrder", zase.d(var2.getOrder()));
         }

         if (!var2.k()) {
            var1.a("paperSize", zase.y(var2.getPaperSize()));
         }

         if (var2.getZoom() != 100) {
            var1.a("scale", zase.y(var2.getZoom()));
         }

         if (var3 != null) {
            var1.a("r:id", var3);
         }

         var1.b();
      }
   }

   private void b(zcfx var1, PageSetup var2) throws Exception {
      String var3 = var2.a(true, 2);
      String var4 = var2.a(false, 2);
      String var5 = var2.a(true, 0);
      String var6 = var2.a(false, 0);
      String var7 = var2.a(true, 1);
      String var8 = var2.a(false, 1);
      if (var3.length() > 0 || var4.length() > 0 || var5.length() > 0 || var6.length() > 0 || var7.length() > 0 || var8.length() > 0 || var2.isHFDiffOddEven() || var2.isHFDiffFirst() || !var2.isHFScaleWithDoc() || !var2.isHFAlignMargins()) {
         var1.b("headerFooter");
         if (var2.isHFDiffOddEven()) {
            var1.a("differentOddEven", "1");
         }

         if (var2.isHFDiffFirst()) {
            var1.a("differentFirst", "1");
         }

         if (!var2.isHFScaleWithDoc()) {
            var1.a("scaleWithDoc", "0");
         }

         if (!var2.isHFAlignMargins()) {
            var1.a("alignWithMargins", "0");
         }

         if (var7.length() > 0) {
            this.a(var1, "oddHeader", var7);
         }

         if (var8.length() > 0) {
            this.a(var1, "oddFooter", var8);
         }

         if (var5.length() > 0) {
            this.a(var1, "evenHeader", var5);
         }

         if (var6.length() > 0) {
            this.a(var1, "evenFooter", var6);
         }

         if (var3.length() > 0) {
            this.a(var1, "firstHeader", var3);
         }

         if (var4.length() > 0) {
            this.a(var1, "firstFooter", var4);
         }

         var1.b();
      }

   }

   private void a(zcfx var1, String var2, String var3) throws Exception {
      var1.b(var2);
      if (var3.startsWith(" ") || var3.endsWith(" ")) {
         var1.a("xml:space", (String)null, "preserve");
      }

      var1.a(var3);
      var1.b();
   }

   private void c(zcfx var1) throws Exception {
      var1.b("sheetViews");
      var1.b("sheetView");
      if (!this.b.isGridlinesVisible()) {
         var1.a("showGridLines", "0");
      }

      if (!this.b.isRowColumnHeadersVisible()) {
         var1.a("showRowColHeaders", "0");
      }

      if (this.b.isSelected() || this.b.m() == this.a.getWorksheets().getActiveSheetIndex()) {
         var1.a("tabSelected", "1");
      }

      var1.a("workbookViewId", "0");
      if (this.b.isPageBreakPreview()) {
         var1.a("view", "pageBreakPreview");
      }

      if (this.b.getZoom() != 100) {
         var1.a("zoomScale", zase.y(this.b.getZoom()));
      }

      if (this.b.getCharts().get(0).getSizeWithWindow()) {
         var1.a("zoomToFit", "1");
      }

      var1.b();
      var1.b();
   }

   private void d(zcfx var1) throws Exception {
      String var2 = null;
      if (this.b.g != null) {
         var2 = this.b.g.e;
      }

      String var3 = this.b.k;
      if (var2 != null || !this.d.isPercentScale() || var3 != null || !this.b.j.a()) {
         var1.b("sheetPr");
         if (var3 != null) {
            var1.a("codeName", var3);
         }

         if (var2 != null) {
            var1.a("published", var2);
         }

         if (!this.d.isPercentScale()) {
            var1.b("pageSetUpPr");
            var1.a("fitToPage", "1");
            var1.b();
         }

         if (!this.b.j.a()) {
            zty.a(var1, this.b.j, "tabColor");
         }

         var1.b();
      }

   }
}
